<?php

namespace app\api\logic;

use think\facade\Config;

class AddressBookLogic extends BaseSDKLogic
{
    // 获取部门列表
    public function department($deptId = 1)
    {
        $configDing = Config::get('ding');
        $http = new HttpLogic();
        $response = $http->request('POST',$configDing['host_old'].'/topapi/v2/department/listsub',[
            'query' => ['access_token' => $this->accessToken()],
            'json' => [
                'dept_id' => $deptId
            ]
        ]);
        return $response['result'];
    }

    // 获取部门详情
    public function departmentDetails($deptId)
    {
        $configDing = Config::get('ding');
        $http = new HttpLogic();
        $response = $http->request('POST',$configDing['host_old'].'/topapi/v2/department/get',[
            'query' => ['access_token' => $this->accessToken()],
            'json' => [
                'dept_id' => $deptId
            ]
        ]);
        return $response['result'];

    }

    //获取部门用户基础信息
    public function listSimpleUser($deptId)
    {
        $configDing = Config::get('ding');
        $http = new HttpLogic();
        $response = $http->request('POST',$configDing['host_old'].'/topapi/user/listsimple',[
            'query' => ['access_token' => $this->accessToken()],
            'json' => [
                'dept_id' => $deptId,
                'cursor' => 0,
                'size' => 100

            ]
        ]);

        return $response['result'];

    }

    public function listDetailsUser($deptId)
    {
        $configDing = Config::get('ding');
        $http = new HttpLogic();
        $response = $http->request('POST',$configDing['host_old'].'/topapi/v2/user/list',[
            'query' => ['access_token' => $this->accessToken()],
            'json' => [
                'dept_id' => $deptId,
                'cursor' => 0,
                'size' => 100

            ]
        ]);

        return $response['result'];

    }
}